package com.cy.pj.sys.dao;

import com.cy.pj.sys.pojo.SysUser;
import com.cy.pj.sys.pojo.SysUserDept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SysUserDao {

       @Update("update sys_users set password=#{newPassword},salt=#{newSalt},modifiedTime=now() where username=#{username}")
       int updatePassword(String username,String newPassword,String newSalt);

       /**基于用户名查找用户信息*/
       @Select("select * from sys_users where username=#{username}")
       SysUser findUserByUserName(String username);

       /**查询当前用户以及用户对应的部门信息*/
       SysUserDept findObjectById(Integer id);

       int updateObject(SysUser entity);
       int insertObject(SysUser entity);

       @Update("update sys_users set valid=#{valid},modifiedUser=#{modifiedUser},modifiedTime=now() where id=#{id}")
       int validById(Integer id,Integer valid,String modifiedUser);

       int getRowCount(String username);
       List<SysUserDept> findPageObjects(String username,Integer startIndex,Integer pageSize);
}
